var http = require('http');
var express = require('express');
var path = require('path');
var app = express(); //生成一个express实例 app

// app.set('views', path.join(__dirname, 'build/html')); //设置存放视图文件或者说模版文件的目录
app.use(express.static(path.join(__dirname, 'build/html'))); //设置存放 image、css、js 等静态文件的目录

app.all('/**', function (req, res, next) {
	res.header('Access-Control-Allow-Credentials', 'true');
	res.header("Access-Control-Allow-Origin", "*");
	res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
	res.header("Access-Control-Allow-Headers", "X-Requested-With,cache-control,content-type,hash-referer");
	next();
});

app.get('/**', function (req, res) {
	res.header('Cache-Control', 'no-cache');
	res.sendFile(path.join(__dirname, 'build/html/index.html'));
});

app.post('/Home/Login', function (req, res) {
	res.send({
		code: 1,
		token: 'dfgsdfsdf'
	})
	res.end();
});


//创建http服务器
var server = http.createServer(app);

//监听端口
server.listen(7810);
console.log('端口:' + 7810)
